﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="news_page_browse.aspx.cs" Inherits="Ccit.OA.NewsCenter.news_page_browse" %>
<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" style="height:98%" >
<head runat="server">
    <title>信息中心-信息浏览</title>
    <link href="../CSS/enter.css" rel="stylesheet" type="text/css" />
    <script language="javascript" src="../script/jquery.js" type="text/javascript"></script>
    <script language="javascript" src="../script/StringClass_Ext.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jsonlib.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jcontrol.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jwindow.js" type="text/javascript"></script>
    <script src="../script/jbase64.js" type="text/javascript"></script>
    <!--板块拖动-->
    <script language="javascript" src="../script/lib/prototype.js" type="text/javascript"></script>
    <script language="javascript" src="../script/scriptaculus/scriptaculous.js" type="text/javascript"></script>    
    <script language="javascript" src="../script/scriptaculus/dragdrop.js" type="text/javascript"></script>
    <script language="javascript" src="../script/scriptaculus/effects.js" type="text/javascript"></script>
    
    <style type="text/css">
        
        *{padding:0;margin:0}
        
        ul.sortabledemo li {
          
        }
        .moveCell {
            cursor: move;
        }
        
        .tdCellSel{border:red dashed 1px} 
        .tdCellUnSel{border:white;border-width:0 0 0 0}
        
        input.button {
	        background: url(images/bg_button.gif); border-style: solid; border-width: 1px;
	        color: #666666; cursor: hand; font-family: 宋体;font-size: 9pt; height: 19px;
	        line-height: 9pt; padding-bottom: 3px; padding-left: 1px; padding-right: 1px; padding-top: 3px;
        }
        .tbToolbar
        {   
            BACKGROUND-COLOR: #CCCCCC;BORDER-RIGHT: #CCCCCC 1px solid; PADDING-RIGHT: 0px;  BORDER-LEFT: #CCCCCC 1px solid;    
            PADDING-LEFT: 3px;BORDER-BOTTOM: #CCCCCC 0px solid;PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px;HEIGHT: 27px; width: 98%;
            BACKGROUND-COLOR: transparent; background-image: url(../images/title_bg.gif); 
	    }

        .input {
	        background: url(images/bg_input.gif);
	        background-color: #FFFFFF;
	        border-color: #999999;
	        border-style: solid;
	        border-width: 1px;
	        height: 20px;
	        left: 0px;
	        top: 0px;
	        vertical-align: center;
        }
        .checkbox {
	        font-family: verdana, helvetica, sans-serif, 宋体;
	        font-size: 12px;
	        vertical-align: middle;
        }	    
    </style>
    <script type="text/javascript" type="text/javascript">
       //设置布局页面
       function  doSet(){
          var vPageParam = "Type="+$get("_hidType").value;
		  var encodeParam = base64encode(vPageParam); 
          document.location="news_page_set.aspx?"+encodeParam;
       }
     
      //弹出选择Logo页面
      function doSelLogo() {
            var strURL = "sys_logo_sel.aspx";
            OpenWindow(strURL,"",560,350);
        }
        //返回选择图片的路径
        function doSetPlateLogo(picName) {            
            document.getElementById("_hidImgPath").value = picName;
            document.getElementById("imgLogo").style.display="inline";
            var imgCtrl = document.getElementById("imgLogo");
            imgCtrl.src = picName;
        }
        
        //属性设置 
        var selColor = "#CDCECF";
        
        //获取选中颜色
        function setcolor(elem){
          var oriHtCell;
          var destHtCell;
          
          if(selColor == elem) return;
          
          if(null != selColor && selColor !="undefined") {
             oriHtCell = findColorCell(selColor);
             oriHtCell.className = "tdCellUnSel";
          }      
          
          destHtCell = findColorCell(elem);
          destHtCell.className = "tdCellSel";
          selColor = elem;
          document.getElementById("_hidBorderColor").value=elem;
        }
        function findColorCell(colorSign) {
            var trPanel = document.getElementById("trColorPanel");
            var cellCount = trPanel.cells.length;
            var htcell;
            for(var i = 0; i < cellCount; i ++) {
                htcell = trPanel.cells(i);
                if(htcell.bgColor.toUpperCase() == colorSign.toUpperCase()) {
                    return htcell;
                }
            }
        }
         
         
        //设置属性
        function doSetWinAttr(vplateId,vUserId){
                var _hidPlateId=$get("_hidPlateId").value;
                if(_hidPlateId!="")  //第一次点击
                {   
                    doCancle();
                }
                $get("_hidPlateId").value=vplateId;
                var vType = document.getElementById("_hidType").value;
                PageMethods.GetPlateObj(vplateId,vType,vUserId,ClientCallBack);
        }
        
        function ClientCallBack(vResult){
            var array = vResult.split("~");
            var type=array[0];
            switch(type){
               case "GetPlateObj" :
                    var obj=array[1];
                    eval("var vResultObj="+obj);
                    $get("_hidPlateId").value=vResultObj.plateId;
                    $get("txtPlateName").value=vResultObj.plateName;
                    
                    if(array[2]!=""){
                        $get("_hidImgPath").value=array[2];
                        var imgCtrl = document.getElementById("imgLogo");
                        imgCtrl.style.display = "inline";
                        imgCtrl.src = array[2];
                    }else
                    {
                        var imgCtrl = document.getElementById("imgLogo");
                        imgCtrl.style.display = "none";
                    }
                    if(vResultObj.titleStyle == "" || vResultObj.titleStyle == null)
                    {
                          $get("_hidBorderColor").value="#CDCECF";
                          setcolor("#CDCECF");
                    }
                      
                    else
                    {
                         $get("_hidBorderColor").value="#"+vResultObj.titleStyle;
                         setcolor("#"+vResultObj.titleStyle);
                    }
                    $get("txtShowNum").value=vResultObj.showNo;
                    if(vResultObj.showDate=="1")
                      $get("cbkShowDate").checked=true;
                    if(vResultObj.showCreator=="1")
                      $get("cbkShowCreateor").checked=true;
                      
                    var divAttr=$get("divSetAttr"); //设置属性div
                    
                    var showDiv=$get("div_"+vResultObj.plateId); //显示数据div
                    var datatTbl=$get("tbl_data_"+vResultObj.plateId);//数据
                    
                    showDiv.appendChild(divAttr);
                    
                    divAttr.style.display="block";
                    datatTbl.style.display="none";
                    break;
               case "EditPlate" :
                    eval("var vResultObj="+array[1]);
                    var vPageParam = "Type="+$get("_hidType").value;
		            var encodeParam = base64encode(vPageParam); 
                    alert(vResultObj.resMes);
                    if(vResultObj.resFlag > 0)
                    {
                      document.location="news_page_browse.aspx?"+encodeParam;
                    } 
                    break;     
            }
            
        }
        //取消
        function  doCancle(){
            var plateId=$get("_hidPlateId").value;
            var divAttr=$get("divSetAttr"); //设置属性div
            
            var showDiv=$get("div_"+plateId); //显示数据div
            var datatTbl=$get("tbl_data_"+plateId);//数据
            
            showDiv.appendChild(datatTbl);
            
            divAttr.style.display="none";
            datatTbl.style.display="block";
        }
        //确定
        function doEdit(){
          if(!checkNum()) return ;
          var WinStyle={};
          WinStyle.PlateId=$get("_hidPlateId").value;
          WinStyle.PlateName=$get("txtPlateName").value;
          WinStyle.PlateLogo=$get("_hidImgPath").value;
          WinStyle.TitleStyle=$get("_hidBorderColor").value;
          WinStyle.ShowNum=$get("txtShowNum").value;
          if($get("cbkShowDate").checked)
              WinStyle.ShowPubTime="1";
           else
              WinStyle.ShowPubTime="0";  
          if($get("cbkShowCreateor").checked)
              WinStyle.ShowCreateor="1";  
          else
              WinStyle.ShowCreateor="0";
          var vType = document.getElementById("_hidType").value;
          var vUserId = document.getElementById("_hidSysPlateId").value;
          var jsonExpr=JSON.stringify(WinStyle,function(key,value){return value;});
          PageMethods.EditPlate(jsonExpr,vType,vUserId,ClientCallBack);
        }
        
        
        //验证
       function checkNum(){
          var showNum=document.getElementById("txtShowNum").value;
          if(showNum!=""&&!showNum.IsNumber())
          {
             alert("显示数字必须填数字");
             return false;
          }
          return true;
       }
       
       function ResizeImage(_image) {
			    var max_width = 310; 
			    var max_height = 210;
			    var _width = _image.width;
			    var _height = _image.height;
			    var width_ratio = _width / max_width;
			    var height_ratio = _height / max_height;
			    //alert("Width ratio:" + width_ratio + ", Height Ratio:" + height_ratio);
			    
			   // if ( width_ratio >= height_ratio) {
			        _image.width = max_width;
			  //  }
			   // else { 
			        _image.height = max_height;
			  //  }
			}
       
        function OnLoad() {
            var imgnews=document.getElementsByTagName("img");
            var imgLength = imgnews.length;
            for(var i = 0; i<imgLength;i++)
            {
                var imgItem = imgnews[i];
                if(imgItem.id==null||imgItem.id=="undefined") continue;
                var imgIndex = imgItem.id.indexOf("_imgnews");
                if(imgIndex!=-1)
                {
                    ResizeImage(imgItem);
                }
            }
            var cellCount = document.getElementById("_hidCellCount").value;
            if(cellCount != "" && cellCount > 0) {
                var sortId_one = "sort_1";
                var sortId_two = "sort_2";
                var sortId_three = "sort_3";
                switch(cellCount) {
                    case "1":
                        Sortable.create(sortId_one,
                         {dropOnEmpty:true,containment:[sortId_one],constraint:false});
                        break;
                    case "2":
                        Sortable.create(sortId_one,
                         {dropOnEmpty:true,containment:[sortId_one,sortId_two],constraint:false});
                        Sortable.create(sortId_two,
                         {dropOnEmpty:true,containment:[sortId_one,sortId_two],constraint:false});
                         break;
                    case "3":
                        Sortable.create(sortId_one,
                         {dropOnEmpty:true,containment:[sortId_one,sortId_two,sortId_three],constraint:false});
                        Sortable.create(sortId_two,
                         {dropOnEmpty:true,containment:[sortId_one,sortId_two,sortId_three],constraint:false});
                        Sortable.create(sortId_three,
                         {dropOnEmpty:true,containment:[sortId_one,sortId_two,sortId_three],constraint:false});
                        break;
                }                
            }
        }
    </script>
</head>
<body style="height:94%" onload="OnLoad()">
    <ccit:ActionForm  id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"></asp:ScriptManager>
    <input type="hidden" id="_hid1" runat="server" value="90" />
    <input type="hidden" id="_hid2" runat="server"  value="4"/>
    
    <input type="hidden" id="_hidSysPlateId" runat="server"  value="4"/>
    
    <input type="hidden" id="_hidUserId" runat="server" />
    <input type="hidden" id="_hidCellCount" runat="server" />
    <input type="hidden" id="_hidType" runat="server" />
    <table class="tbToolbar" cellpadding="0" cellspacing="0" width="98%" align="center">
        <tr>
            <td align="right" width="96%">
                <nobr>
                  <a onclick="doSet()" style="cursor:hand"><img src="../images/edit_logo/EVENTS.GIF" height="25" width="25" /></a> &nbsp; 
                </nobr>
            </td>
            <td align="right">
                <nobr>
                  <a onclick="doSet()" style="cursor:hand"> 设置 </a> &nbsp; 
                </nobr>
            </td>
        </tr>
    </table>
   
    <asp:Label ID="lblShowMes" runat="server" Text=""></asp:Label>
    
    <table id="tblFrame" runat="server" width="98%" height='99%' align="center" border="0" cellpadding="0" cellspacing="0"> 
        <tr>
            <td id="tdOneFrm" valign="top" height='100%' runat="server"></td>
            <td id="tdTwoFrm" valign="top" height='100%'  runat="server"></td>
            <td id="tdThreeFrm" valign="top" height='100%'  runat="server"></td>            
        </tr>       
    </table>
    
    
    <!--设置属性-->
    
    <!--编辑是板块ID-->
    <input type="hidden" value="" id="_hidPlateId" runat="server" />
    <!--选中颜色-->
    <input type="hidden" value="" id="_hidBorderColor" runat="server" />
    <!--选择logo图片路径-->
    <input name="_hidImgPath" type="hidden" id="_hidImgPath" runat="server" />   
    
    <div id="divSetAttr" style="display:none;">
    <table id="tblSetAttr" cellpadding="0" cellspacing="0" width="98%" border="0">
            <tr>
                <td>
                  <fieldset id="fildAttr" style="width:90%; height:90%; text-align:center" runat="server" >
                    <legend>窗口基本属性</legend>
                     <table  cellpadding="0" cellspacing="0"  width="100%" border="0">
                        <tr>
                          <td width="28%"  align="right">窗口名称&nbsp;</td>
                          <td  align="left" style="padding-left:10px">
                             <input type="text" value="" id="txtPlateName" runat="server" style="width:90%" class="input"/>
                          </td>
                        </tr>
                        <tr>
                          <td width="28%" align="right">LOGO&nbsp;</td>
                          <td align="left"  style="padding-left:10px">
                            <nobr> 
                                <img alt="" id="imgLogo" runat="server" style="height:24; width:24; "/>
                                <a id="A1" runat="server" href="javascript:doSelLogo()">选择图片</a>
                            </nobr>
                          </td>
                        </tr>
                        <tr>
                          <td width="28%" valign="middle" align="right">边框颜色&nbsp;
                          </td>
                          <td align="left"  style="padding-left:10px">
                              <TABLE cellSpacing="0" cellPadding="0"  width=100  border="0">
                                <TBODY>
                                <TR>
                                  <TD width="98%" >
                                    <TABLE cellSpacing="5" cellPadding="0"  width="100%" border="0">
                                      <TBODY>
                                      <TR id="trColorPanel">
                                        <TD bgColor="#CDCECF" style="cursor:hand" width=15 height=15 class="tdCellSel" onclick="setcolor('#CDCECF')">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
                                        <TD bgColor="#CCFFFF" style="cursor:hand" width=15 height=15 onclick="setcolor('#CCFFFF')">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
                                        <TD bgColor="#FFFFCC" style="cursor:hand" width=15 height=15 onclick="setcolor('#FFFFCC')">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
                                        <TD bgColor="#FFCCCC" style="cursor:hand" width=15 height=15 onclick="setcolor('#FFCCCC')">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
                                        <TD bgColor="#CC66FF" style="cursor:hand" width=15 height=15 onclick="setcolor('#CC66FF')">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>                                            
                                        <TD bgColor="#FFFF00" style="cursor:hand" width=15 height=15 onclick="setcolor('#FFFF00')">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
                                        <TD bgColor="#123456" style="cursor:hand" width=15 height=15 onclick="setcolor('#123456')">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
                                      </TR>
                                      </TBODY>
                                    </TABLE>
                                   </TD>
                                 </TR>
                                 </TBODY>
                               </TABLE>
                          </td>
                        </tr>
                        <tr>
                          <td width="28%"  align="right">显示条数&nbsp;</td>
                          <td  align="left"  style="padding-left:10px">
                            <input type="text" value="" id="txtShowNum" runat="server" style="width:25px" class="input" /><font style="color:Red">　0表示显示全部记录</font>
                          </td>
                        </tr>
                        <tr>
                          <td width="28%"  align="right">显示日期&nbsp;</td>
                          <td align="left"  style="padding-left:10px"><asp:CheckBox ID="cbkShowDate" runat="server" CssClass="checkbox"></asp:CheckBox>&nbsp;显示</td>
                        </tr>
                        <tr>
                          <td width="28%"  align="right">显示创建人&nbsp;</td>
                          <td align="left"  style="padding-left:10px">
                              <asp:CheckBox ID="cbkShowCreateor" runat="server" CssClass="checkbox"></asp:CheckBox>&nbsp;显示
                          </td>
                        </tr>
                        <tr style="padding:5px">
                          <td align="right">
                             <input type="button" class="button" value="确定" onclick="doEdit()" /></td>
                          <td align="center">
                             <input type="button" value="取消" class="button" onclick="doCancle()" />
                          </td>
                        </tr>
                    </table>                    
                  </fieldset>
                </td>
            </tr>
        </table>
    </div>
    </ccit:ActionForm>
</body>
</html>
